package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.ContactUserEntity;
import com.xbongbong.saas.domain.entity.PurchaseUserEntity;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * 供应商负责人
 * @author Jian.Wang
 * @date 2019/1/30 16:41
 * @since v1.0
 * @version v1.0
 */
public interface PurchaseUserModel extends IModel<PurchaseUserEntity> {
    /**
     * 查询协同团队基础列表
     * @param map 参数
     * @return 团队
     */
    List<UserTeamEntity> findBaseEntitys(Map<String,Object> map);

    /**
     * 保存
     *
     * @param purchaseUserEntity 实体
     * @return 成功
     * @throws XbbException 异常
     */
    Integer save(PurchaseUserEntity purchaseUserEntity) throws XbbException;

    /**
     * 获取协同团队的业务数据
     * @param corpid 公司id
     * @param isMain 负责或协同
     * @param userId 用户id
     * @return List<Long>
     */
    List<Long> getDataIdList(String corpid, Integer isMain, List<String> userId);

    PurchaseUserEntity getByKey(Long teamUserId, String corpid);

    void delete(PurchaseUserEntity purchaseUserEntity) throws XbbException;
    /**
     * Description: 获取采购合同团队
     * @param corpid
     * @param purchaseId
     * @param isMain
     * @return java.util.List<com.xbongbong.saas.domain.entity.PurchaseUserEntity>
     * @author 魏荣杰
     * @date 2019/4/29 15:22
     * @since v1.0
     */
    List<PurchaseUserEntity> getPurchaseUserListByPurchaseId(String corpid, Long purchaseId, Integer isMain);

    @Override
    Integer insert(PurchaseUserEntity entity) throws XbbException;

    @Override
    Integer update(PurchaseUserEntity entity) throws XbbException;

    @Override
    List<PurchaseUserEntity> findEntitys(Map<String, Object> param);

    @Override
    Integer getEntitysCount(Map<String, Object> param);

    void insertBatch(List<PurchaseUserEntity> purchaseUserEntityList, boolean isImport) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    /**
     * Description: 获取合同负责人或协同人id list
     * @param corpid 公司id
     * @param purchaseId 采购合同id
     * @param isMain 是否为负责人 1负责人 0 协同人
     * @return java.util.List<java.lang.String>
     * @author chenshan
     * @date 2019/3/6 17:15
     * @since v1.0
     */
    List<String> getPurchaseUserIdList(String corpid, Long purchaseId, Integer isMain);

    /**获取合同负责人或协同人id list
     * @param corpid 公司id
     * @param purchaseIds 采购合同id集合
     * @param isMain 是否为负责人 1负责人 0 协同人
     * @return java.util.List<java.lang.String>
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    List<String> getPurchaseUserIdList(String corpid, List<String> purchaseIds, Integer isMain);

    /**
     * 批量剔除团队
     * @param corpid
     * @param removeIdList 客户团队表idList
     */
    Map<Long, String> batchDeleteById(String corpid, List<Long> removeIdList) throws XbbException;

    /**
     * 删除
     * @param purchaseUserEntityList
     * @param corpid
     * @param del
     * @throws XbbException
     */
    void deleteBatchUser(List<PurchaseUserEntity> purchaseUserEntityList, String corpid, Integer del) throws XbbException;


    /**
     * 批量编辑
     * @param list
     * @param corpid
     * @return
     * @throws XbbException
     */
    Integer updateBatch(List<PurchaseUserEntity> list, String corpid) throws XbbException;

    void deletByDataIds(List<Long> dataIds, String corpid) throws XbbException;


    /**
     * 编辑团队成员标签
     *
     * @param purchaseUserEntity
     */
    void editLabel(PurchaseUserEntity purchaseUserEntity) throws XbbException;

    /**
     * 更新协同人可编辑权限
     *
     * @param purchaseUserEntity
     */
    void updateEditFormPer(PurchaseUserEntity purchaseUserEntity) throws XbbException;

    /**
     * 更新团队协同人信息和协同人可编辑权限
     *
     * @param corpid
     * @param idIn
     * @param updateUserToCoTeamList
     * @param coopUser
     * @param needThrow
     */
    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> updateUserToCoTeamList, Integer coopUser, boolean needThrow) throws XbbException;

    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;
}
